package org.phnq.stack;

import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import org.phnq.babel.*;
import org.phnq.babel.types.*;

/**
 * <<Class summary>>
 *
 * @author Patrick Gostovic &lt;&gt;
 * @version $Rev$
 */
public class PhnqHttpObjectFactory
{
	public JSValue createObject(JSArray args)
	{
		HttpServletRequest req = PhnqRequestContext.getCurrent().getRequest();
		JSObject http = new JSObject();
		JSObject params = new JSObject();
		http.put("params", params);
		
		for(Enumeration en=req.getParameterNames(); en.hasMoreElements();)
		{
			String name = (String)en.nextElement();
			String val = req.getParameter(name);
			params.put(name, new JSString(val));
		}
		
		return http;
	}
}
